package com.usian.controller;

import com.usian.User;
import com.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * ?占位符
     * @param userId
     * @return
     */

    @RequestMapping("findUserByUserId/{userId}")
    public User findUserByUserId(@PathVariable Integer userId){
        return userService.findByUserId(userId);
    }

    /**
     * ?  传参
     * @param id
     * @return
     */

    @RequestMapping("/findById")
    public User findById(Integer id){
        return  userService.findById(id);
    }

    /**
     * 传递对象
     * @param user
     * @return
     */
    @RequestMapping("/insertUser")
    public  String insertUser(@RequestBody User user){
        String s = userService.insertUser(user);
        return  s;
    }




}
